#  工具类

#  copy
import os.path


def copy(source, target):
    if not os.path.exists(target):
        os.mkdir(target)
    if os.path.isdir(source) and os.path.isdir(target):
        file_list = os.listdir(source)
        for file in file_list:
            path = os.path.join(source, file)
            with open(path, 'rb') as r_stream:
                content = r_stream.read()
                target_file = os.path.join(target, file)
                with open(target_file, 'wb') as w_stream:
                    w_stream.write(content)
        else:
            print("拷贝完成！")


# 调用函数
src = os.getcwd()
print(src)
tgt = os.path.join(src, "new_copy_file")
src = "E:\\workspace\\python\\demo-python\\dictionary"
print(tgt)
copy(src, tgt)
